<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta content="user-scalable=no,width=device-width, initial-scale=1" id="viewport" name="viewport" initial-scale="1">

		<script language="javascript" type="text/javascript" src="../js/js/baseJs.js"></script>

	</head>
	<body style="background:#f5f9ff">

		<div class="gold-seed-center" id="goldSeedCenter" style="display: none;">
			<div class="wap-header" style="background: #323848;">金种子中心
				<a class="back" onClick="javascript:window.history.back();return false;"></a>
			</div>
			<div class="gold-wrapper">
				<div class="header-c">
					<div class="ico-tuan" v-if="isTeamLeader"></div>
					<div class="ico" v-else></div>
					<div class="number-c">
						<div class="title">LZB数量</div>
						<div class="number">{{goldSeedAccountData.jzzNumber}}枚</div>
						<div class="unit">（挖矿所得：{{goldSeedAccountData.jzzNumberDig}}枚）</div>
					</div>
					<div class="total-price">
						≈{{getTotalPrice(goldSeedAccountData)}}
					</div>
				</div>	
				<div class="line-c-price">
					<div class="price-c">
						<div class="price">￥{{goldSeedAccountData.currentPrice}}</div>
						<div class="title">当日价格</div>
					</div>
					<div class="up-number">距发售：↑<span>{{getUpPercent(goldSeedAccountData)}}%</span></div>
				</div>
				<div class="line-c-common" @click="showMessage()">
					<div class="ico-1"></div>
					<div class="title">交易大厅</div>
				</div>
				<a class="line-c-common" @click="goMyBusiness()">
					<div class="ico-2"></div>
					<div class="title">我的交易</div>
				</a>
			</div>
		</div>
		<script src="../js/js/rem_fix.js"></script>
		<script src="../js/js/common.js"></script>
		<script type="text/javascript">
			var token = getCookie("userToken");
			var userId = getCookie("userId");
			var accountType = getCookie("accountType");
			console.log(token)
			console.log(userId)
			console.log(accountType)
			var projectId = parseInt(window.location.hash.split("#")[1]);
			var loginUrl = "../userBundle/login.mobile.html";

			var goldSeedCenterApp = new Vue({
				el: '#goldSeedCenter',
				data: {
					userData: '',
					downLineUsers: [],
					isDoingFetchData: false,
					goldSeedAccountData:'',
					accountType:accountType,
					downLineUsers:'',
					isTeamLeader:false
				},
				ready: function() {
					if (!token || !userId) {
						window.location.href = loginUrl;
					} else {						
						this.fetchData();
						this.fetctUserData()
					}
				},
				filters: {
					userCategory: function(key) {
						key = parseInt(key);
						var map = {
							1: "普通用户",
							2: "vip用户",
							3: "pos联盟股东",
						};
						return map[key];
					}
				},
				methods: {
					showMessage:function(){
						window.location.href="./tradingCenter.mobile.html"
					},
					goMyBusiness:function(){
						window.location.href='./myJzzBusiness.mobile.html'
					},
					fetctUserData:function(){
						var url = "/user/getUserById";
						var data = {
							client: 1,
							token: token,
							userId: parseInt(userId)
						}
						pushData(url, data, function(res) {
							console.log(res)
							if (res.state) {
								this.downLineUsers = res.data.downLineUsers;
								this.isTeamLeader=res.data.isTeamLeader;
							} else if (res.errorCode == 008) {
								window.location.href =loginUrl;
							} else {
								alert(res.message)
							}
						}.bind(this))
					},
					fetchData:function(){
						if(this.isDoingFetchData){
							return
						}
						this.isDoingFetchData=true;
						var url="/jzz/flow/user/getUserJzzInfo";
						var data={
							client: 1,
							token: token,
							userId: parseInt(userId)
						}
						pushData(url,data,function(res){
							if(res.state){
								this.goldSeedAccountData=res.data.userInfo
								$("#goldSeedCenter").show();
							}else{
								alert(res.message)
							}
						}.bind(this))
					},
					getTotalPrice:function(goldSeedAccountData){
						return "￥"+(parseFloat(goldSeedAccountData.currentPrice)*parseFloat(goldSeedAccountData.jzzNumber)).toFixed(4)
					},
					getUpPercent:function(goldSeedAccountData){
						if(parseFloat(goldSeedAccountData.currentPrice)==100){
							return 0
						}else{
							return parseFloat(goldSeedAccountData.currentPrice)/100	
						}
						
					},
					logoutAccount: function() {
						delCookie("userToken");
						delCookie("userId");
						delCookie("invitationCode");
						window.location.href = loginUrl;
					},
				}
			})
		</script>

	</body>
</html>
